/**
 * Copyright (c) 2013-Now http://jeesite.com All rights reserved.
 */
package com.jeesite.modules.goods.web;

import java.util.Date;
import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.jeesite.common.config.Global;
import com.jeesite.common.entity.Page;
import com.jeesite.common.mybatis.mapper.query.QueryType;
import com.jeesite.common.web.BaseController;
import com.jeesite.modules.config.MyProps;
import com.jeesite.modules.goods.entity.ZtGoods;
import com.jeesite.modules.goods.entity.ZtQuanself;
import com.jeesite.modules.goods.service.ZtQuanselfService;
import com.jeesite.modules.sys.entity.User;
import com.jeesite.modules.sys.service.UserService;

/**
 * 测试数据Controller
 * 
 * @author ThinkGem
 * @version 2018-04-22
 */
@Controller
@RequestMapping(value = "${adminPath}/ztQuanself")
public class ZtQuanselfController extends BaseController {

	@Autowired
	private ZtQuanselfService ztQuanselfService;
	

	
	@Autowired  
    private MyProps myProps;

	
	

	/**
	 * 获取数据
	 */
	@ModelAttribute
	public ZtQuanself get(String id, boolean isNewRecord) {
		ZtQuanself ztQuanself=new ZtQuanself();
		ztQuanself.setId(id);
		return ztQuanselfService.get(ztQuanself);
	}

	/**
	 * 查询列表
	 */
	
	@RequestMapping(value = { "list", "" })
	public String list(ZtQuanself ztQuanself, Model model) {
		model.addAttribute("ztQuanself", ztQuanself);
		
		
		return "modules/ztQuanself/ztQuanselfList";
	}

	/**
	 * 查询列表数据
	 */
	
	@RequestMapping(value = "listData")
	@ResponseBody
	public Page<ZtQuanself> listData(ZtQuanself ztQuanself, HttpServletRequest request,
			HttpServletResponse response,Model model) {
		
		
		Page<ZtQuanself> page = ztQuanselfService.findPage(new Page<ZtQuanself>(request,
				response), ztQuanself);
		//usestatus
		for(ZtQuanself zsf:page.getList()){
			if(zsf.getZtQuan().getToTime()!=null && zsf.getZtQuan().getToTime().getTime()<System.currentTimeMillis()){
				zsf.setUsestatus("1");
			}
		}
		
		/*String pathPx=myProps.getServerPath();
		for(ZtQuanself zd:page.getList()){
			String img="";
			try{
			 img=myProps.getServerPath()+ztQuanselfService.getImgFirst(zd);
			}catch(Exception ex){
				img="";
			}
			zd.setImgs(img);
		}*/
		
		return page;
	}
	
	

	
	
}